package com.aspose.cells.a.c;

public class zm {
   public static int a(double var0) {
      return (new Double(var0)).hashCode();
   }

   public static double a(double var0, int var2) {
      return a(var0, var2, (byte)0);
   }

   public static double a(double var0, int var2, boolean var3) {
      return a(var0, var2, (byte)(var3 ? 1 : -1));
   }

   private static double a(double var0, int var2, byte var3) {
      if (var0 != 0.0D && var2 <= 630 && (var2 <= 307 || var0 < 1.0D && var0 > -1.0D)) {
         boolean var4;
         if (var0 < 0.0D) {
            var4 = true;
            var0 = -var0;
         } else {
            var4 = false;
         }

         int var5;
         if (var0 >= 1.0D) {
            var5 = (int)Math.log10(var0);
         } else {
            var5 = (int)Math.floor(Math.log10(var0));
         }

         var2 += var5;
         if (var2 > 307) {
            return var4 ? -var0 : var0;
         } else if (var2 < -324) {
            return 0.0D;
         } else {
            double var6 = Math.pow(10.0D, (double)(var2 - var5));
            var0 *= var6;
            switch(var3) {
            case -1:
               var0 = Math.floor(var0);
               break;
            case 1:
               var0 = Math.ceil(var0);
               break;
            default:
               if (var2 >= -10) {
                  var0 = Math.floor(var0 + 0.5D + Math.pow(10.0D, (double)(var2 - 15)));
               } else {
                  var0 = Math.floor(var0 + 0.5D);
               }
            }

            return (var4 ? -var0 : var0) / var6;
         }
      } else {
         return var0;
      }
   }

   public static double b(double var0, int var2) {
      if (var2 <= 15 && var0 != 0.0D && var0 < 9.223372036854776E18D && var0 > -9.223372036854776E18D) {
         boolean var3 = false;
         if (var0 < 0.0D) {
            var3 = true;
            var0 = -var0;
         }

         int var4 = (int)Math.floor(Math.log10(var0));
         if (var4 + var2 > 18) {
            return var3 ? -var0 : var0;
         } else {
            if (var2 == 0) {
               var0 = (double)((long)(var0 + 0.5D));
            } else {
               double var5 = Math.pow(10.0D, (double)var2);
               var0 = (double)((long)(var0 * var5 + 0.50000000000001D)) / var5;
            }

            if (var3 && var0 != 0.0D) {
               var0 = -var0;
            }

            return var0;
         }
      } else {
         return var0;
      }
   }

   public static double a(String var0) {
      return Double.parseDouble(var0);
   }
}
